package com.heyue.demo;

import com.youlv.yl.bo.UserNameLoginBo;
import com.youlv.yl.config.RedisKeyConfig;
import com.youlv.yl.controller.UserController;
import com.youlv.yl.manager.impl.OssServiceImpl;
import com.youlv.yl.service.impl.UserServiceImpl;
import com.youlv.yl.util.DateUtils;
import com.youlv.yl.util.JedisUtils;
import com.youlv.yl.util.JwtUtils;
import com.youlv.yl.util.TokenUtils;
import org.junit.jupiter.api.Test;

import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;

/**
 * @author fenghe
 * @date 2022/1/10 17:15
 */
class Mytest {
    @Test
    void t1() {
        System.out.println(JwtUtils.createToken("17860308685"));
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(JwtUtils.createToken("17860308685"));
    }
    @Test
    void t2() {
        System.out.println(new OssServiceImpl());
    }
    @Test
    void t3() {
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.DAY_OF_MONTH, -1);
        System.out.println(calendar);
        System.out.println(new Date());
        boolean b = DateUtils.dateEq(new Date(), DateUtils.getDateByDay(0));
        System.out.println(b);

        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
        System.out.println(df.format(new Date()));// new Date()为获取当前系统时间
    }

    @Test
    void t4() {
        JedisUtils.expire("yl:auth:token:eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxNzg2MDMwODY4NSJ9.3EC8zJncU3SIP372hfd8UDs3DlByp2s3xbTP-Z1HCmY", RedisKeyConfig.USER_TOKEN_TIME);
    }

    @Test
    void bubblingSort() {
        int[] arr = {1, 3, 5, 7, 9, 2, 4, 6, 8};

        for (int i = 0; i < arr.length - 1; i++) {
            for (int j = 0; j < arr.length - i - 1; j++) {
                if(arr[j] > arr[j +1]) {
                    arr[j] ^= arr[j +1];
                    arr[j +1] ^= arr[j];
                    arr[j] ^= arr[j +1];
                }
            }
        }
        System.out.println(Arrays.toString(arr));
    }

    @Test
    void quicksort() {
        String s = DateUtils.CurrentTime();
        Date date = DateUtils.stringToDate(s);
        System.err.println(date);
        long a = date.getTime() - new Date().getTime();
        System.err.println(a / (1000 * 60));
    }

    @Test
    void binarySearch() {

    }
}
